package pl.edu.agh.inpema.core.components.impl;

import java.util.HashSet;
import java.util.Set;

import pl.edu.agh.inpema.core.components.GlobalAnalyzerUtil;
import pl.edu.agh.inpema.core.dataBase.DataBase;
import pl.edu.agh.inpema.core.model.AnalyzeResult;
import pl.edu.agh.inpema.core.model.Analyzer;

public class GlobalAnalyzerUtilImpl implements GlobalAnalyzerUtil {
	
	private Set<Analyzer> analyzers;
	private DataBase dataBase;
	private int[] envIds;
	
	public GlobalAnalyzerUtilImpl(Set<Analyzer> analyzers, DataBase dataBase, int[] envIds) {
		this.analyzers = analyzers;
		this.dataBase = dataBase;
		this.envIds = envIds;
	}
	
	public Set<Analyzer> getAllAnalyzers() {
		return this.analyzers;
	}
	
	public Set<AnalyzeResult> getAllAnalyzeResultsForAnalyzer(Analyzer analyzer) {
		
		//return this.dataBase.getAllAnalyzeResults(analyzer.getAnalyzerUtil().getAnalyzerName());
		
		Set<AnalyzeResult> result = new HashSet<AnalyzeResult>();
		for (int envId : this.envIds)
			result.addAll(this.dataBase.getAllAnalyzeResults(analyzer.getAnalyzerUtil().getAnalyzerName(), envId));
		return result;
	}

}
